subroutine wmbej_iefmn_t2bfjn(wmbej, iabij,& 
              t2, icore, fact)
!
use mod_iop
use mod_size
use mod_ioff
use mod_orbit 
implicit none
!
real*8, intent(in) :: fact
real*4, intent(in) :: wmbej(*)
real*4, intent(in) :: iabij(*)
!
real*4, intent(inout) :: t2(*)
real*4, intent(inout) :: icore(*)
!
real*8 fact
!
integer :: i, j, a, b, nsize, i0, i1, i2, i3, i4
integer, external
real*8, external :: dnrm2
i0 = 1
i1 = i0 + nvvoo*isd
i2 = i1 + nvvoo*isd 
i3 = i2 + nvvoo*isd
!this is to do wmbej = wmbej + 0.5*t2(bf,jn)*<ef||mn>
!====EMBJ AAAA
!----<EF||MN>*T2(FB,JN)
!iabij(EF,MN) to iabij(EM,FN)
call myicopyso(iabij(ioi3(2)), icore(i2), nioi32) 
call isymtrso(iabij(ioi3(2)), icore(i3), vrta, vrta, 1, 1, popa, popa, 1, 0, 1) 
call axpyso(nioi32, -1.d0, icore(i3), 1, icore(i2), 1)
call sstgenso(icore(i2), icore(i0), nsize, vrta, vrta, popa, popa,& 
               icore, 1, '1324') 
!t2(BF,JN) to t2(BJ,FN)
call myicopyso(t2(ioi3(2)), icore(i2), nioi32) 
call isymtrso(t2(ioi3(2)), icore(i3), vrta, vrta, 1, 1, popa, popa, 1, 0, 1) 
call axpyso(nioi32, -1.d0, icore(i3), 1, icore(i2), 1)
call sstgenso(icore(i2), icore(i1), nsize, vrta, vrta, popa, popa, &
               icore, 1, '1324')
call VpqmnVrsmn_to_Vpqrs(icore(i0), icore(i1), 1, 1, &
                  vrta, popa, 1, vrta, popa, 1, vrta, popa, 1, & 
                  wmbej(ioi4(1)), 1, fact, 1.d0)
!====EMbj AABB 
!---<EF|MN>*t2(bF,jN)=<EF|MN>*t2(Fb,Nj)
call sstgenso(t2(ioi3(2)), icore(i2), nsize, vrta, vrtb, popa, popb, &
               icore, 1, '1324')
call VpqmnVmnrs_to_Vpqrs(icore(i0), icore(i2), 1, 1, &
                  vrta, popa, 1, vrta, popa, 1, vrtb, popb, 1, &
                  wmbej(ioi4(5)), 1, fact, 1.d0)
!====EMbj AABB 
!---<Ef|Mn>*t2(bf,jn)
call sstgenso(iabij(ioi3(2)), icore(i2), nsize, vrta, vrtb, popa, popb, &
               icore, 1, '1324')
call VpqmnVrsmn_to_Vpqrs(icore(i2), icore(i1), 1, 1, &
                  vrtb, popb, 1, vrta, popa, 1, vrtb, popb, 1, &
                  wmbej(ioi4(5)), 1, fact, 1.d0)
!====EMBJ AAAA
!---<Ef||Mn>*T2(Bf,Jn) AAAA
call sstgenso(iabij(ioi3(2)), icore(i0), nsize, vrta, vrtb, popa, popb,&
               icore, 1, '1324')
call sstgenso(t2(ioi3(2)), icore(i1), nsize, vrta, vrtb, popa, popb, &
               icore, 1, '1324')
call VpqmnVrsmn_to_Vpqrs(icore(i0), icore(i1), 1, 1, &
                  vrtb, popb, 1, vrta, popa, 1, vrta, popa, 1, &
                  wmbej(ioi4(1)), 1, fact, 1.d0)
!====EmBj ABAB 0.5*t2(bf,jn)*<ef||mn>
!---<Ef|mN>*t2(Bf,jN)=<Ef|Nm>*t2(Bf,Nj)
call sstgenso(iabij(ioi3(2)), icore(i0), nsize, vrta, vrtb, popa, popb,&
               icore, 1, '1423')
call sstgenso(t2(ioi3(2)), icore(i1), nsize, vrta, vrtb, popa, popb, &
               icore, 1, '1423')
call VpqmnVrsmn_to_Vpqrs(icore(i0), icore(i1), 1, 1, &
                  vrtb, popa, 1, vrta, popb, 1, vrta, popb, 1, &
                  wmbej(ioi4(2)), 1, fact, 1.d0)
return
end
